<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>编辑渠道</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css">
    <link rel="stylesheet" href="${re.contextPath}/plugin/ztree/css/metroStyle/metroStyle.css">
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.all.js"
            charset="utf-8"></script>
    <script type="text/javascript"
            src="${re.contextPath}/plugin/ztree/js/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/ztree/js/jquery.ztree.excheck.js"
            charset="utf-8"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/tools/update-setting.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var flag = '${detail}';
            if (flag) {
                $("form").disable();
            }
        });
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            var flag = '${detail}';
            if (flag) {
                $("form").disable();
            }
        });
    </script>
</head>

<body>
<div class="x-body">
    <form class="layui-form layui-form-pane" style="margin-left: 20px;">
        <div style="width:100%;height:400px;overflow: auto;">
            <div class="layui-form-item">
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
                    <legend style="font-size:16px;">渠道信息</legend>
                </fieldset>
            </div>
            <div class="layui-form-item">
                <label for="channelName" class="layui-form-label">
                    渠道名称
                </label>
                <div class="layui-input-inline">
                    <input value="${channel.id}" type="hidden" name="id">
                    <input type="text" value="${channel.channelName}" id="channelName" name="channelName" lay-verify="channelName"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label for="channelDesc" class="layui-form-label">
                        渠道描述
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" value="${channel.channelDesc}" id="channelDesc" name="channelDesc" lay-verify="channelDesc" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label for="catalog" class="layui-form-label">
                        catalog
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" value="${channel.catalog}" id="catalog" name="catalog" lay-verify="catalog" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label for="channelSchema" class="layui-form-label">
                        schema(库名)
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" value="${channel.channelSchema}" id="channelSchema" name="channelSchema" lay-verify="channelSchema" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
            </div>
            <div style="height: 60px"></div>
        </div>
    <#if !detail>
        <div style="width: 100%;height: 55px;background-color: white;border-top:1px solid #e6e6e6;
  position: fixed;bottom: 1px;margin-left:-20px;">
            <div class="layui-form-item" style=" float: right;margin-right: 30px;margin-top: 8px">

                <button class="layui-btn layui-btn-normal" lay-filter="add" lay-submit>
                    确认
                </button>
                <button class="layui-btn layui-btn-primary" id="close">
                    取消
                </button>
            </div>
        </div>
    </#if>
    </form>
</div>
<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
                , layer = layui.layer;

        //自定义验证规则
        form.verify({
            channelName: function (value) {
                if (value.trim() == "") {
                    return "渠道名称不能为空";
                }
            },
            channelDesc: function (value) {
                if (value.trim() == "") {
                    return "渠道描述不能为空";
                }
            },
            catalog: function (value) {
                if (value.trim() == "") {
                    return "catalog不能为空";
                }
            },
            channelSchema: function (value) {
                if (value.trim() == "") {
                    return "schema不能为空";
                }
            }
        });

        $('#close').click(function () {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });
        //监听提交
        form.on('submit(add)', function (data) {
            layerAjax('updateChannel', data.field, 'channelList');
            return false;
        });
    });
</script>
</body>

</html>
